<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1-4参考滚动父级元素是body-祖先元素上加一个比sticky元素小的高度，可以实现sticky效果吗</title>
</head>

<body>
    <div class="container">
        container
        <div class="parent">
            parent
            <div class="child">
                child
                <div class="box">box</div>
            </div>
        </div>
        <div class="borther"></div>
    </div>
    <style>
        .container {
            width: 700px;
            height: 2900px;
            margin-top: 200px;
            background-color: bisque;
            padding-top: 80px;
            /* overflow: auto; */
        }

        .parent {
            padding-top: 80px;
            width: 600px;
            height: 500px;
            /*祖先元素高度设置了500px*/
            background-color: aqua;
        }

        .child {
            width: 500px;
            padding-top: 50px;
            height: 1600px;
            /*最近父级元素设置高度1600px*/
            background-color: red;
        }

        .box {
            width: 500px;
            height: 200px;
            background-color: blueviolet;
            position: sticky;
            top: 0;
        }
    </style>

</body>

</html>